package com.yuezhi.consumer.Listener;

import com.yuezhi.consumer.constant.QueueConstant;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;


/**
 * 发布订阅模式 （Topic 交换机）
 * 消费者
 */
@Component
public class TopicReceiver {

    @RabbitListener(queues = QueueConstant.TOPIC_QUEUE_ONE)
    public void handlerOne(Message<String> message)  {
        System.out.println("TopicReceiver[1]:《" + message.getPayload() +"》");
    }

    @RabbitListener(queues = QueueConstant.TOPIC_QUEUE_TWO)
    public void handlerTwo(Message<String> message)  {
        System.out.println("TopicReceiver[2]:《" + message.getPayload() +"》");
    }

    @RabbitListener(queues = QueueConstant.TOPIC_QUEUE_THREE)
    public void handlerThree(Message<String> message)  {
        System.out.println("TopicReceiver[3]:《" + message.getPayload() +"》");
    }
}
